using System;
using System.ComponentModel;
using System.Xml.Serialization;

namespace com.exceptionalsoftware.spacetime.KML
{
	[Serializable()]
    [XmlType(TypeName = "CameraType")]
    public class Camera : ObjectType
	{
        private double longitudeField, latitudeField, altitudeField, headingField;
        private double tiltField, rollField;
        private AltitudeModeEnum altitudeModeField;

        public Camera()
        {
            this.longitudeField = 0;
            this.latitudeField = 0;
            this.altitudeField = 0;
            this.headingField = 0;
            this.tiltField = 0;
            this.rollField = 0;
            this.altitudeModeField = AltitudeModeEnum.ClampToGround;
        }

        [XmlElement(ElementName = "altitudeMode", Type = typeof(AltitudeModeEnum))]
        [DefaultValue(AltitudeModeEnum.ClampToGround)]
        public AltitudeModeEnum AltitudeMode
        {
            get { return this.altitudeModeField; }
            set { this.altitudeModeField = value; }
        }

        [XmlElement(ElementName = "altitude", DataType = "double")]
        [DefaultValue(0)]
        public double Altitude
        {
            get { return this.altitudeField; }
            set { this.altitudeField = value; }
        }

        [XmlElement(ElementName = "latitude", DataType = "double")]
        [DefaultValue(0)]
        public double Latitude
        {
            get { return this.latitudeField; }
            set { this.latitudeField = Coordinate.NormalizeToFixedLimits(value, -90, 90); }
        }

        [XmlElement(ElementName = "longitude", DataType = "double")]
        [DefaultValue(0)]
        public double Longitude
        {
            get { return this.longitudeField; }
            set { this.longitudeField = Coordinate.NormalizeToRepeatingLimits(value, -180, 180); }
        }

        [XmlElement(ElementName = "roll", DataType = "double")]
        public double Roll
        {
            get { return this.rollField; }
            set { this.rollField = value; }
        }

        [XmlElement(ElementName = "tilt", DataType = "double")]
        [DefaultValue(0)]
        public double Tilt
        {
            get { return this.tiltField; }
            set { this.tiltField = Coordinate.NormalizeToFixedLimits(value, 0, 90); }
        }

        [XmlElement(ElementName = "heading", DataType = "double")]
        [DefaultValue(0)]
        public double Heading
        {
            get { return this.headingField; }
            set { this.headingField = Coordinate.NormalizeToRepeatingLimits(value, -360, 360); }
        }

    }
}